<template>
	<view class="container">
		<view class="title">
			<view>共{{qingdanList.length}}件商品</view>
			<!-- <view>编辑</view> -->
		</view>
		<view class="content">
			<view class="list" v-for="(item,index) in qingdanList" :key="index"
				@click="$gourl('/mallPage/goodsDetails?id='+item.id)">
				<image :src="item.product_thumb" mode=""></image>
				<view class="info">
					<view class="name">{{item.product_name}}</view>
					<!-- <view class="sku">规格：1kg/份</view> -->
				</view>
				<view class="price">
					￥{{item.product_price}}
				</view>
			</view>
		</view>
		<u-loadmore v-if="page < count" :status="status" />
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [{
					name: '收入'
				}, {
					name: '支出'
				}],
				current: 0,
				page: 1,
				pageSize: 10,
				count: 1,
				total: 1,
				status: 'loadmore',
				qingdanList: []
			}
		},
		onLoad() {
			this.getData()
		},
		methods: {
			async getData() {
				await this.$allApi.qingdanList({
					page: this.page,
					pageSize: this.pageSize,
				}).then(res => {
					let datas = res.data.list.data
					if (this.page == 1) {
						this.qingdanList = datas
						this.count = Math.ceil(res.data.list.total / res.data.list.per_page)
					} else {
						this.qingdanList = this.qingdanList.concat(datas)
						if (this.page >= this.count) this.status = 'nomore';
					}
				})
			},
			change(index) {
				this.current = index;
			},
		}
	}
</script>

<style scoped lang="scss">
	.price {
		color: #40AE36;
		font-size: 32rpx;
	}

	.content {
		margin-top: 20rpx;
	}

	.title {
		font-size: 24rpx;
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.list {
		width: 710rpx;
		background: #fff;
		border-radius: 10rpx;
		padding: 20rpx;
		display: flex;
		align-items: flex-end;
		justify-content: space-between;
		margin-bottom: 20rpx;

		image {
			width: 140rpx;
			height: 140rpx;
			border-radius: 16rpx;

		}

		.info {
			flex: 1;
			height: 140rpx;
			padding: 16rpx 0;
			padding-left: 20rpx;
			display: flex;
			flex-direction: column;
			justify-content: space-between;

			.sku {
				color: #999;
				font-size: 20rpx;
				margin-top: 20rpx;
			}
		}
	}

	.container {
		min-height: 100vh;
		background: #F8F8F8;
		padding: 20rpx;
	}
</style>